import { ref, onMounted, onUnmounted } from "vue";
function useScreenSize() {
  const NavBarHeight = uni.getStorageSync("NavBarHeight");
  const Height = uni.getStorageSync("windowHeight");
  const isIphoneX = uni.getStorageSync("isIphoneX");
  const clientHeight = ref(Height);
  const handleResize = () => {
    // #ifdef H5
    clientHeight.value = document.body.clientHeight - NavBarHeight - 6;
    // #endif
  };
  onMounted(() => {
    // #ifdef H5
    window.addEventListener("resize", handleResize);
    handleResize();
    // #endif
  });
  onUnmounted(() => {
    // #ifdef H5
    window.removeEventListener("resize", handleResize);
    // #endif
  });

  return {
    windowHeight: clientHeight,
    NavBarHeight,
    isIphoneX,
  };
}

export default useScreenSize;
